Skip to content

ci: run cargo audit on a schedule and open a fix PR - #220

Open
alukach wants to merge 2 commits into
mainfrom
worktree-scheduled-audit
Open

alukach wants to merge 2 commits into
mainfrom
worktree-scheduled-audit

Conversation

@alukach

@alukach alukach commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

What I'm changing

Adds .github/workflows/audit.yml: a scheduled cargo audit run every other
day that hands a red result to claude-code-action to fix and open a PR.

The audit job in ci.yml only fires on push/pull_request, so a new
RustSec advisory filed against a dependency we haven't touched sits unnoticed
until somebody happens to open a PR. #214 (h2 / RUSTSEC-2026-0258) was exactly
that shape, found and fixed by hand.

How I did it

Reuses two patterns already in the repo rather than adding anything new:

  • The scheduled-check-plus-failure-handler shape from contract.yml, including
    letting the run go red — a live advisory with a green scheduled run is a
    silent alarm.
  • The claude-code-action@v1 invocation and the branch → template → gh pr create instructions from claude.yml, in automation mode (prompt:) rather
    than tag mode.

The prompt is deliberately conservative:

  • It checks gh pr list --search "cargo audit in:title" first and stops if a
    fix PR is already open, so a repeated failure doesn't stack duplicate PRs.
  • It must verify both cargo audit and cargo check --target wasm32-unknown-unknown pass before opening the PR, so a cargo update that
    breaks the wasm build doesn't reach review.
  • Advisories with no fixed version (unmaintained/unsound crates, or transitive
    deps we don't control) are explicitly not to be forced — it opens the PR with
    what it could fix and says what's left.

--allowedTools is scoped to the cargo/git/gh commands the job actually needs.

How to test it

workflow_dispatch is enabled, so: Actions → Security Audit → Run workflow.
cargo audit passes on main today, so a manual run should be green and skip
the Claude step entirely. To exercise the fix path, temporarily pin a crate with
a known advisory on a scratch branch and dispatch from there.

PR Checklist

  • This PR has no breaking changes.
  • I have updated or added new tests to cover the changes in this PR.
  • This PR affects the Source Cooperative Frontend & API,
    and I have opened issue/PR #XXX to track the change.

Not applicable — CI-only change, no test surface and no frontend/API impact.

Related Issues

None. Note for the reviewer: the 14 open Dependabot alerts on this repo are all
npm, not cargo, so they are a separate gap this workflow does not close.

The audit job in ci.yml only fires on push/PR, so a new advisory against an
unchanged dependency sits unnoticed until someone opens a PR. Run the same
check every other day and hand a red result to claude-code-action to fix,
guarded by an open-PR dedupe check.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GDiqUGkJRdMfb4b9Xak7DJ
@github-actions

github-actions Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

🚀 Latest commit deployed to https://source-data-proxy-pr-220.source-coop.workers.dev

  • Date: 2026-11-17T04:39:33Z
  • Commit: 4728879

alukach added a commit that referenced this pull request Sep 25, 2026
## What I'm changing

`cargo audit` fails on `main`, and so the Security Audit check fails on
every open PR, including the machine-identity PRs (#232, #235). The
cause is a new advisory against rustls 0.23.42,
[RUSTSEC-2026-0285](https://rustsec.org/advisories/RUSTSEC-2026-0285):
TLS 1.3 handshake messages were accepted across encryption-level
boundaries. It is patched in 0.23.45. This bumps the lockfile to it.

## How I did it

`cargo update -p rustls --precise 0.23.45`. A plain `cargo update -p
rustls` stops at 0.23.43; the precise bump moves aws-lc-rs to 1.18.1,
aws-lc-sys to 0.45.0 and rustls-webpki to 0.103.15 with it. `Cargo.lock`
only.

rustls never reaches the Worker. `cargo tree -i rustls --target
wasm32-unknown-unknown` prints nothing; natively it comes in through
multistore → reqwest → hyper-rustls, which the native tests use.
Production was not exposed.

## How to test it

- `cargo audit`: no vulnerabilities, with the one allowed warning
(chacha20) CI already allows.
- The pre-commit hook: `cargo fmt --check`, `cargo clippy --target
wasm32-unknown-unknown -- -D warnings`, `cargo check --target
wasm32-unknown-unknown` and `cargo test`, all passing.

## PR Checklist

- [x] This PR has **no** breaking changes.
- [x] I have updated or added new tests to cover the changes in this PR.
(None apply: lockfile only.)
- [x] This PR does not affect the Source Cooperative Frontend & API.

## Related Issues

Unblocks the Security Audit check on #232, #235 and the PRs stacked on
#235 (#236, #237); their pull-request runs check out the merge with
`main`, so a re-run passes once this lands. #220 would catch the next
one on a schedule. Part of source-cooperative/source.coop#491 only in
that it clears CI for it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01R1eiTse4416N6uTgAy4Ddd

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch was previously deployed

1 inactive deployment
preview — d9dc8425 Deployed Nov 17, 2026 by alukach via Deploy & Test / Deploy #497
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant